package com.xpffly.design.composite.demo.service.impl;

import com.xpffly.design.composite.demo.service.IBranch;
import com.xpffly.design.composite.demo.service.ILeaf;

import java.util.ArrayList;

/**
 * @Author: 午夜学徒
 * @Date: 2022/3/25 15:22
 * @Description：
 */
public class Branch implements IBranch {
    /**
     * 存储子节点信息
     */
    private ArrayList subOrdinateList = new ArrayList();
    /**
     * 树枝节点名称
     */
    private String name;
    /**
     * 树枝节点职位
     */
    private String position;
    /**
     * 树枝节点薪水
     */
    private int salary = 0;

    public Branch(String name, String position, int salary) {
        this.name = name;
        this.position = position;
        this.salary = salary;
    }

    public String getInfo() {
        return "名称：" + this.name + "\t职位：" + this.position + "\t薪水：" + this.salary;
    }

    public void add(IBranch iBranch) {
        this.subOrdinateList.add(iBranch);
    }

    public void add(ILeaf iLeaf) {
        this.subOrdinateList.add(iLeaf);
    }

    public ArrayList getSubordinateInfo() {
        return this.subOrdinateList;
    }
}
